import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import { defineConfig } from "vite";
import { terser } from "rollup-plugin-terser";

export default defineConfig({
  plugins: [vue()],
  build: {
    outDir: "dist/lib",
    lib: {
      entry: resolve(__dirname, "src/lib/index.ts"),
      name: "Circle",
      fileName: (format) => `circle.${format}.js`,
    },
    rollupOptions: {
      external: ["vue"],
      output: {
        // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
        globals: {
          vue: "Vue",
        },
        plugins: [terser()],
      },
    },
  },
});
